All Questions
18 questions
2votes
0answers
101views
How to Use Webpack with WordPress Script Modules and Enqueue a Custom Class
I am working on a WordPress project using version 6.5, which introduced support for JavaScript modules. I have a parent theme that exports a JavaScript class, and I want to import this class in a ...
0votes
0answers
151views
wp_enqueue_script JS code runs too late (after user begins interacting)
The issue is that we need to replace some HTML based on the user's user agent string but by the time the JS code is loaded and runs, the user is already interacting with the page. Is there some way to ...
0votes
0answers
63views
Why can I not deregister my style and script on custom post type?
I have a website where I have a custom post type with some single pages attached to it. Problem: I can't deregister the scripts and styles on my custom post type single pages. This is my code: ...
1vote
1answer
766views
My scripts-bundle.js file is getting sent to the browser as a stylesheet css file. Help!
I'm new to WordPress custom theme development. I am using a child theme for OceanWP. I have a webpack setup to hot-reload my files but my js scripts are not getting sent to my WordPress site instead ...
1vote
1answer
737views
Why won't my scripts load?
I am having trouble loading scripts in functions.php I've done this before so I'm sure I'm overlooking something but as far as I can tell it is correct and I have tried copying and pasting from other ...
0votes
1answer
66views
Javascript asset not enqueuing with the rest
I am working on a project that uses the child-theme's functions file to enqueue a stylesheet and a single javascript file. These two resources are enqueued well. However, when I add a new compiled ...
3votes
3answers
1kviews
wp_register_script multiple identifiers?
In order to avoid poor performance with multiple <script> tags I do concatenation of scripts regularly and produce one single bundle.min.js JS file and 'jsbundle' identifier. Problem is, things ...
0votes
1answer
224views
Why is JavaScript being added to header as application/oembed?
I created a short JavaScript file and placed it in my theme's JS folder, the contents of the file are: /** * Text2Give Functions File * * Mobile Landing Page Functions File */ jQuery( function( $...
2votes
2answers
5kviews
How to properly add Bootstrap and JQuery Javascripts?
I am developing my WordPress theme using Material Bootstrap Design (MDB), a Material variant that uses Bootstrap 4 plus its own code. It calls for using the following scripts... <!-- JQuery -->...
3votes
1answer
808views
wp_enqueue_script adds only the first script
function banana_scripts() { wp_enqueue_script('grid', get_stylesheet_directory_uri() . '/js/jquery.min.js', null, null); wp_enqueue_script('grid', get_stylesheet_directory_uri() . '/js/...
0votes
1answer
110views
Dequeue set-post-thumbnail.min.js
Want to alter the behavior how set-post-thumbnail works (add additional functionality upon successful set post thumbnail). Looking on how to dequeue the stock set-post-thumbnail.min.js script so I can ...
4votes
1answer
6kviews
How to get a jQuery script to run on a page?
I am having a hard time figuring out how to get a jQuery script to run on a Wordpress page of mine the "correct" way. I have followed this article and implemented what the first answer says to do. ...
0votes
1answer
250views
JavaScript Libraries in WordPress
I understand that in order to use a JavaScript library in WordPress, such as jQuery, we have to use the following code to prevent conflicts: function my_scripts_method() { wp_enqueue_script( '...
2votes
1answer
3kviews
How do I enqueue(or delay loading of) <script> tags in individual page posts?
My customer has many pages with <script> elements including javascript. <script src="myscriptforthispageonly.js"></script> I'm trying to get all scripts to load in the footer using ...
2votes
2answers
7kviews
Including javascript for a shortcode
I'm creating a plugin that allows a user to use a shortcode. This shortcode depends on a bunch of javascript that needs to be present once the shortcode loads. I'm having issues trying to decide when ...